package com.cptravel.activity;

import android.os.Bundle;
import android.view.View;
import com.baidu.mapapi.map.BaiduMap;
import com.baidu.mapapi.map.BaiduMapOptions;
import com.baidu.mapapi.map.MapStatus;
import com.baidu.mapapi.map.MapView;
import com.baidu.mapapi.model.LatLng;
import com.core.controller.B5MBaseActivity;

/**
 * @author yushilong
 * @date 2014-10-21 上午11:24:07
 * @version 1.0
 */
public class MapActivity extends B5MBaseActivity
{
    private MapView mMapView;
    private BaiduMap mBaiduMap;

    @Override
    protected String getHeadTitle()
    {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    public int doGetContentViewId()
    {
        // TODO Auto-generated method stub
        return 0;
    }

    @Override
    public boolean isNoTitle()
    {
        // TODO Auto-generated method stub
        return true;
    }

    @Override
    public View doGetContentView()
    {
        // TODO Auto-generated method stub
        Bundle bundle = getIntent().getExtras();
        double lat = bundle.getDouble("lat");
        double lng = bundle.getDouble("lng");
        LatLng p;
        if (lat != 0 && lng != 0)
        {
            p = new LatLng(lat, lng);
        }
        else
        {
            p = new LatLng(39.904965, 116.327764);//默认定位到北京
        }
        mMapView = new MapView(this, new BaiduMapOptions().mapStatus(new MapStatus.Builder().target(p).build()));
        return mMapView;
    }

    @Override
    public void doInitSubViews(View containerView)
    {
        // TODO Auto-generated method stub
    }

    @Override
    public void doInitDataes()
    {
        // TODO Auto-generated method stub
        mBaiduMap = mMapView.getMap();
    }

    @Override
    public void doAfter()
    {
        // TODO Auto-generated method stub
    }

    @Override
    protected void onPause()
    {
        // TODO Auto-generated method stub
        super.onPause();
        mMapView.onPause();
    }

    @Override
    protected void onResume()
    {
        // TODO Auto-generated method stub
        super.onResume();
        mMapView.onResume();
    }

    @Override
    protected void onDestroy()
    {
        // TODO Auto-generated method stub
        super.onDestroy();
        mMapView.onDestroy();
    }
}
